home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Resources / Burning & Media / GB-PVR 1.2.13 / GBPVR10213.msi / Cabs.w1.cab / Stub_Library_aspx_cs.cs55 < prev    next >
Text File  |  2007-02-18  |  3KB  |  99 lines

  1. //===========================================================================
  2. // This file was generated as part of an ASP.NET 2.0 Web project conversion.
  3. // This code file 'App_Code\Migrated\Stub_Library_aspx_cs.cs' was created and contains an abstract class 
  4. // used as a base class for the class 'Migrated_Library' in file 'Library.aspx.cs'.
  5. // This allows the the base class to be referenced by all code files in your project.
  6. // For more information on this code pattern, please refer to http://go.microsoft.com/fwlink/?LinkId=46995 
  7. //===========================================================================
  8.  
  9.  
  10. using System;
  11. using System.Collections;
  12. using System.ComponentModel;
  13. using System.Data;
  14. using System.Drawing;
  15. using System.Globalization;
  16. using System.IO;
  17. using System.Text.RegularExpressions;
  18. using System.Xml;
  19. using System.Web;
  20. using System.Web.SessionState;
  21. using System.Web.UI;
  22. using System.Web.UI.WebControls;
  23. using System.Web.UI.HtmlControls;
  24. using GBPVR.Public;
  25.  
  26.  
  27. namespace gbweb
  28.  {
  29.  
  30.  
  31. abstract public class Library :  System.Web.UI.Page
  32. {
  33.         public static string GetRealPath(string vpath)
  34.         {
  35.             string[] pathparts = vpath.Split(new char[] {'/'}, 3);
  36.             string Mode = CultureInfo.CurrentUICulture.TextInfo.ToTitleCase(pathparts[0]);
  37.  
  38.             Hashtable directories = (Hashtable)HttpContext.Current.Session[Mode + "LibraryDirectories"];
  39.             if (directories == null)
  40.             {
  41.  
  42.                 string directorylist = "Video~|Music~";
  43.                 XmlNode node = Global.Config.SelectSingleNode("/settings/" + Mode + "LibraryDirectory");
  44.                 if (node != null)
  45.                 {
  46.                     directorylist = node.InnerText;
  47.                 }
  48.  
  49.                 string[] directorymappings = directorylist.Split('|');
  50.                 directories = new Hashtable();
  51.                 foreach (string directorymapping in directorymappings)
  52.                 {
  53.                     string[] mapping = directorymapping.Split('~');
  54.                     if ((directorymapping.Length > 0) && (mapping.Length > 1))
  55.                         directories[mapping[0]] = mapping[1];
  56.                 }
  57.                 HttpContext.Current.Session[Mode + "LibraryDirectories"] = directories;
  58.             }
  59.  
  60.             string path = null;
  61.             if (pathparts.Length == 2)
  62.             {
  63.                 path = (string)directories[pathparts[1]];
  64.             }
  65.             else if (pathparts.Length == 3)
  66.             {
  67.                 path = Path.Combine((string)directories[pathparts[1]], pathparts[2].Replace('/', Path.DirectorySeparatorChar));
  68.             }
  69.  
  70.             return path;
  71.         }
  72.         public static Regex GetRegex(string mode)
  73.         {
  74.             string filterRegex;
  75.             switch (mode.ToLower())
  76.             {
  77.                 case "video":
  78.                     filterRegex = Global.Settings.videoFiles;
  79.                     break;
  80.                 case "music":
  81.                     filterRegex = Global.Settings.musicFiles;
  82.                     break;
  83.                 case "photo":
  84.                     filterRegex = Global.Settings.photoFiles;
  85.                     break;
  86.                 default:
  87.                     filterRegex = string.Empty;
  88.                     break;
  89.             }
  90.             return new Regex(filterRegex, RegexOptions.Compiled | RegexOptions.IgnoreCase);
  91.         }
  92.  
  93.  
  94. }
  95.  
  96.  
  97.  
  98. }
  99.